package demo.practice.tree.segment;

public class P152 {

    public int maxProduct(int[] nums) {
        SegmentTreeOperator o = new SegmentTreeOperator(nums, new Operator() {
            @Override
            public int merge(int a, int b) {
                return a * b;
            }
        });

        int res = o.query(0, nums.length - 1);

        for (int i = 0; i < nums.length; i++) {
            for (int j = i; j < nums.length; j++) {
                res = Math.max(res,o.query(i, j));
            }
        }

        return res;

    }
}
